package cn.jsoup;

import com.sun.media.sound.SoftTuning;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;

public class jsoupDemo4 {
    public static void main(String[] args) throws IOException {
        /*
        element
         */
        String path = jsoupDemo4.class.getClassLoader().getResource("student2.xml").getPath();
        Document document = Jsoup.parse(new File("D:\\Ultimate IDEA\\myXML\\out\\production\\Jsoup_Using\\student2.xml"), "utf-8");
        Elements elements = document.getElementsByTag("name");
        String text = elements.text();
        System.out.println(text);

        System.out.println("-----");
        String html = elements.html();
        System.out.println(html);

        System.out.println("-----------------");
        Element element_student = document.getElementsByTag("student").get(0);
        String sex = element_student.attr("id");//根据属性名称获取属性值
        System.out.println(sex);
    }
}
